<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSafetyHazardsTable extends Migration
{
    public function up()
    {
        Schema::create('safety_hazards', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('ID');
            $table->bigInteger('employees_id')->nullable()->comment('员工ID');
            $table->string('location')->comment('隐患位置');
            $table->text('description')->comment('隐患描述');
            $table->text('cover_picture')->comment('图片');
            $table->string('status')->default('pending')->comment('隐患状态[pending:待处理,processing:处理中,rectification:暂时处理,resolved:已处理]');
            $table->text('treatment_measure')->comment('处理措施');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('修改时间');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');

        });

        DB::statement('alter table'. ' ' .config('database.connections.mysql.prefix', '').'safety_hazards comment "安全隐患表"');

    }

    public function down()
    {
        Schema::dropIfExists('safety_hazards');     // 安全隐患表

    }
}
